package com.mk.legoscans2;

import android.content.Context;
import android.content.Intent;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;

public class StartItemOnTouchListener implements OnTouchListener{

	private Context _context;
	private View _searchContainer;
	private Intent _intent;
	
	public StartItemOnTouchListener(Context context, View searchContainer, Intent intent)
	{
		_context = context;
		_searchContainer = searchContainer;
		_intent = intent;
	}
	
	public boolean onTouch(View v, MotionEvent event) {

		switch (event.getAction() & MotionEvent.ACTION_MASK) {
			case MotionEvent.ACTION_DOWN:
				_searchContainer.setBackgroundResource(R.color.on_touch_bg);
				break;
			case MotionEvent.ACTION_UP:
				_searchContainer.setBackgroundResource(0);
				_context.startActivity(_intent);
				break;
			case MotionEvent.ACTION_CANCEL:
				_searchContainer.setBackgroundResource(0);
				break;
			default:
				break;
		}
		return true;
	}

}
